import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Date;
import java.sql.Time;


public class TreatmentRecordGUI extends JPanel {
    int location;
    User user;
    TreatmentRecord tr = new TreatmentRecord();
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_5;
    private JTextField textField_6;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTextField textField_9;
    public TreatmentRecordGUI() {
        setLayout(null);
        
        JLabel lblNewLabel = new JLabel("Treating Doctor");
        lblNewLabel.setBounds(10, 11, 110, 14);
        add(lblNewLabel);
        
        textField = new JTextField();
        textField.setBounds(130, 8, 86, 20);
        add(textField);
        textField.setColumns(10);
        
        JButton btnBack = new JButton("Back");
        btnBack.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = -1;
            }
        });
        btnBack.setBounds(10, 266, 89, 23);
        add(btnBack);
        
        JButton btnEdit = new JButton("Add");
        btnEdit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                tr.setAttendingNurse(textField_1.getText());
                tr.setDate(Date.valueOf(textField_2.getText()));
                tr.setTime(Time.valueOf((textField_5.getText())));
                tr.setTreatingDoctor(textField.getText());
                tr.setSymptoms(textField_3.getText());
                tr.setWeight(Double.parseDouble(textField_9.getText()));
                tr.setPulse(Integer.parseInt(textField_7.getText()));
                tr.setTemperature(Double.parseDouble(textField_8.getText()));
                
                user.addTreatmentRecord(tr);
                location = 1;
                
            }
        });
        btnEdit.setBounds(130, 266, 89, 23);
        add(btnEdit);
        
        textField_1 = new JTextField();
        textField_1.setBounds(130, 39, 86, 20);
        add(textField_1);
        textField_1.setColumns(10);
        
        JLabel lblDate = new JLabel("Date");
        lblDate.setBounds(10, 70, 46, 14);
        add(lblDate);
        
        textField_2 = new JTextField();
        textField_2.setBounds(130, 70, 86, 20);
        add(textField_2);
        textField_2.setColumns(10);
        
        JLabel lblTime = new JLabel("Time");
        lblTime.setBounds(10, 106, 46, 14);
        add(lblTime);
        
        JLabel lblSymptoms = new JLabel("Symptoms");
        lblSymptoms.setBounds(226, 11, 89, 14);
        add(lblSymptoms);
        
        JLabel lblVitals = new JLabel("Vitals");
        lblVitals.setBounds(228, 106, 46, 14);
        add(lblVitals);
        
        textField_3 = new JTextField();
        textField_3.setBounds(226, 39, 214, 56);
        add(textField_3);
        textField_3.setColumns(10);
        
        textField_4 = new JTextField();
        textField_4.setColumns(10);
        textField_4.setBounds(226, 127, 214, 56);
        add(textField_4);
        
        JButton btnViewCharts = new JButton("View Charts");
        btnViewCharts.setBounds(226, 194, 214, 23);
        add(btnViewCharts);
        
        JLabel lblPatient = new JLabel("Patient");
        lblPatient.setBounds(10, 134, 46, 14);
        add(lblPatient);
        
        textField_5 = new JTextField();
        textField_5.setBounds(130, 101, 86, 20);
        add(textField_5);
        textField_5.setColumns(10);
        
        JButton btnAddDoctorsOrders = new JButton("Add Doctors Orders");
        btnAddDoctorsOrders.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 20;
                tr.setAttendingNurse(textField_1.getText());
                tr.setDate(Date.valueOf(textField_2.getText()));
                tr.setTime(Time.valueOf((textField_5.getText())));
                tr.setTreatingDoctor(textField.getText());
                tr.setSymptoms(textField_3.getText());
                tr.setWeight(Double.parseDouble(textField_9.getText()));
                tr.setPulse(Integer.parseInt(textField_7.getText()));
                tr.setTemperature(Double.parseDouble(textField_8.getText()));
            }
        });
        btnAddDoctorsOrders.setBounds(226, 228, 214, 23);
        add(btnAddDoctorsOrders);
        
        JLabel lblAttendingNurse = new JLabel("Attending Nurse");
        lblAttendingNurse.setBounds(10, 36, 110, 14);
        add(lblAttendingNurse);
        
        textField_6 = new JTextField();
        textField_6.setColumns(10);
        textField_6.setBounds(130, 127, 86, 20);
        add(textField_6);
        
        JLabel lblWeight = new JLabel("Weight");
        lblWeight.setBounds(10, 169, 46, 14);
        add(lblWeight);
        
        JLabel lblHeight = new JLabel("Temperature");
        lblHeight.setBounds(10, 194, 89, 14);
        add(lblHeight);
        
        JLabel lblPulse = new JLabel("Pulse");
        lblPulse.setBounds(10, 219, 46, 14);
        add(lblPulse);
        
        textField_7 = new JTextField();
        textField_7.setColumns(10);
        textField_7.setBounds(130, 213, 86, 20);
        add(textField_7);
        
        textField_8 = new JTextField();
        textField_8.setColumns(10);
        textField_8.setBounds(130, 183, 86, 20);
        add(textField_8);
        
        textField_9 = new JTextField();
        textField_9.setColumns(10);
        textField_9.setBounds(130, 158, 86, 20);
        add(textField_9);
    }
    public int getLoc(){
        return location;
    }
    
    public void setLoc(int i){
        location = i;
    }
    
    public TreatmentRecord getTreatmentRecord()
    {
        return tr;
    }
    public void setTreatmentRecord(TreatmentRecord input){
        tr = input;
    }
    
    public User getUser(){
        return user;
    }
    public void setUser(User input){
        user = input;
    }
    
}
